package com.hbvtc.xxxy.nikeSale.frames;

import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

import com.hbvtc.xxxy.nikeSale.daos.SalesmanDao;
import com.hbvtc.xxxy.nikeSale.models.Salesman;

public class SalesmanNike extends JFrame implements ActionListener {
	JButton btnSelect, btnAdd, btnDel, btnUpdate,btnBack;

	public SalesmanNike() {
		this.setTitle("员工信息界面");
		this.setSize(1000, 700);
		this.setLocationRelativeTo(null);
		this.setVisible(true);

		// 设置标题栏的图标
		ImageIcon imageIcon = new ImageIcon(getClass().getResource("01.png"));
		this.setIconImage(imageIcon.getImage());

		// 背景图片的路径
		String path = "images/001.jpg";
		ImageIcon background = new ImageIcon(path);
		// 把背景图片显示在一个标签里面
		JLabel label = new JLabel(background);
		// 把标签的大小位置设置为图片刚好填充整个面板
		label.setBounds(0, 0, this.getWidth(), this.getHeight());
		// 把内容窗格转化为JPanel，否则不能用方法setOpaque()来使内容窗格透明
		JPanel imagePanel = (JPanel) this.getContentPane();
		imagePanel.setOpaque(false);
		// 把背景图片添加到分层窗格的最底层作为背景
		this.getLayeredPane().add(label, new Integer(Integer.MIN_VALUE));
		this.setVisible(true);
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

		this.setLayout(null);
		btnSelect = new JButton("查询所有员工信息");
		btnAdd = new JButton("添加正式员工信息");
		btnDel = new JButton("删除员工信息");
		btnUpdate = new JButton("修改员工信息");
		btnBack = new JButton("返  回");
		this.add(btnSelect);
		this.add(btnAdd);
		this.add(btnDel);
		this.add(btnUpdate);
		this.add(btnBack);
		btnSelect.setBounds(340, 100, 230, 50);
		btnSelect.setFont(new Font(null, 0, 24));
		btnAdd.setBounds(340, 210, 230, 50);
		btnAdd.setFont(new Font(null, 0,24));
		btnDel.setBounds(340, 330, 230, 50);
		btnDel.setFont(new Font(null, 0, 24));
		btnUpdate.setBounds(340, 440, 230, 50);
		btnUpdate.setFont(new Font(null, 0, 24));
		btnBack.setBounds(700, 550, 110, 40);
		btnBack.setFont(new Font(null, 0, 24));
		btnSelect.addActionListener(this);
		btnAdd.addActionListener(this);
		btnDel.addActionListener(this);
		btnUpdate.addActionListener(this);
		btnBack.addActionListener(this);
	}

	public static void main(String[] args) {
		new SalesmanNike().setVisible(true);
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		// TODO Auto-generated method stub
		if (e.getSource() == btnSelect) {
			new SelectSalesmanNike();
		}
		if (e.getSource() == btnAdd) {
			new AddSalesmanNike();
		}
		if (e.getSource() == btnDel) {
			new DelSalesmanNike();
		}
		if (e.getSource() == btnUpdate) {
			new UpdateSalesmanNike();
		}
		if(e.getSource()== btnBack){
			   dispose();
			    new SuccessSalesmanNike();
		   }
	}
}
